package cn.hill4j.tool.spring.std.dispatch.service;

import cn.hill4j.tool.spring.ext.dispatcher.DispatchRoute;
import cn.hill4j.tool.spring.ext.dispatcher.Dispatcher;
import cn.hill4j.tool.spring.ext.dispatcher.exception.DispatchInvokerException;
import org.springframework.stereotype.Service;

@Service
public class MyDispatcher implements Dispatcher<DispatchData,DispatchData> {
    @Override
    public DispatchRoute route(DispatchData requestData, DispatchData context) {
        return new DispatchRoute("test",requestData.getBiz());
    }

    @Override
    public DispatchData resolveContext(DispatchData requestData) {
        return requestData;
    }

    @Override
    public Object[] resolveArgs(DispatchData requestData, DispatchData context) {
        return new Object[]{requestData.getData()};
    }

    @Override
    public Object dispatch(DispatchData requestData) throws DispatchInvokerException {
        return requestData.getName() + ":" + Dispatcher.super.dispatch(requestData);
    }
}
